#include <stdio.h>
#include <stdlib.h>
int main() {
    int num, question;
    scanf("%d", &num);
    int* money = (int*)malloc(num * sizeof(int));
    long long* sum = (long long*)malloc((num + 1) * sizeof(long long));
    for (int i = 0; i < num; i++) {
        scanf("%d", &money[i]);
        sum[i + 1] = sum[i] + money[i];
    }
    scanf("%d", &question);
    long long* ok = (long long*)malloc(question * sizeof(long long));
    for (int i = 0; i < question; i++) {
        int begin, end;
        scanf("%d %d", &begin, &end);
        ok[i] = sum[end] - sum[begin - 1];
    }
    for (int i = 0; i < question; i++) {
        printf("%lld\n", ok[i]);
    }
    return 0;
}